home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / Documentation / Development Notes / ODF Shared Library < prev    next >
Encoding:
Text File  |  1996-09-17  |  11.3 KB  |  249 lines  |  [TEXT/ttxt]

  1. OpenDoc
  2. Development
  3. Framework
  4.                                                                                                                                                                                      
  5. ODF Shared Library 
  6. ODF Release 2                                                                                                                                                             
  7.  
  8. This document provides information about the ODF shared library.
  9.  
  10.  
  11. Table of Contents
  12. -------------------------
  13. • Shipping ODFLibrary
  14. • Release-to-Release Binary Compatibility
  15. • SOM vs. Extern "C" Interfaces
  16. • Public vs Private APIs
  17. • C++ Wrapper Classes
  18. • Smart Pointers
  19. • Publicly Exported Functions (by Subsystem)
  20.  
  21.  
  22. All parts you build with ODF Release 2 require the ODF shared library ODFLibrary 1.1.  ODFLibrary contains code from the Foundation and OS layers of ODF that is shared by all ODF parts.  The design choice to package part of ODF as a shared library has ramifications that you should be aware of when you develop ODF parts.  Those ramifications are covered here.
  23.  
  24.  
  25.  
  26. Shipping ODFLibrary
  27.  
  28. When you build ODF part editors with ODF Release 2, you must link against ODFLibrary 1.1.  When you ship your part editors, you must provide an installer.  Your installer should install the ODFLibrary along with your part editors into the 'Editors' folder. If an ODFLibrary is already present on your system, check the version number. Do not install an older version over a more recent one.  The ODFLibrary will maintain release to release binary compatibility so that older part editors will still work with the most recent version of the library.
  29.  
  30.  
  31.  
  32. Release-to-Release Binary Compatibility
  33.  
  34. When you ship a part built with ODF Release 2, your part editor (for example, WhizzyPart 1.0) and ODFLibrary 1.1 are installed into the user's Editors folder.  Meanwhile, we're busy developing ODF Release 3.  ODF R3 may have an improved ODFLibrary, say version 1.2. Along the way, we may have discovered and fixed bugs in ODFLibrary and released updates on the net, say versions 1.1.1 and 1.1.2.  Any of these versions could be installed into the Editors folder of  your users of WhizzyPart 1.0.   This means that we (the ODF team) must ensure backwards compatibility of ODFLibrary, or we'll break all ODF parts built against prior versions of ODFLibrary.
  35.  
  36. Fortunately, the Code Fragment Manager (CFM) and the CFM Runtime make this relatively easy.  We are not allowed to modify any of the exported APIs, but we can add new APIs, fix bugs, and even completely replace implementations beneath the APIs, and still be backwards compatible.
  37.  
  38. Note that classes and APIs defined in the ODF static libraries (i.e. not part of ODFLibrary) can be modified in future releases of ODF.  This means that when we ship ODF Release 3 (and later) that you may need to modify your source code and rebuild your part editor in order to take advantage of new features and improvements in the architecture.
  39.  
  40.  
  41.  
  42. SOM vs. Extern "C" Interfaces
  43.  
  44. The code in the ODF library is the implementation for much of the Foundation and OS layers of ODF.  The classes in these subsystems were originally designed as C++ classes, but in order to move the code into a shared library it was necessary to rearchitect the code.  Two choices were available to us: 1) convert the classes to SOM, and 2) convert to procedural APIs using C-style structs and functions (extern "C").  We ended up using both mechanisms.  ODFLibrary 1.1 has 21 SOM classes and 491 extern "C" functions.
  45.  
  46.  
  47.  
  48. Public vs Private APIs
  49.  
  50. If you examine the list of exported functions from ODFLibrary you will see that most of them (395, to be exact) are named FW_PrivXXX.  Functions in ODF which begin with the "Priv" prefix are considered private, or internal, to ODF.  These functions are used internally by ODF and should never need to be called by your part editor.  In general, Priv functions are low-level (private) interfaces which are used by the implementation of higher-level (public) interfaces.  This is definitely the case for the Priv functions in ODF Library. For example, ODFLibrary exports 42 private functions that begin with the prefix "FW_PrivString_".  These functions are all implementations for the methods of the public class FW_CString.  FW_CString is a normal C++ class, and is statically linked into every ODF part.  However, every method of FW_CString is implemented as a single call to one of the FW_PrivString functions in ODFLibrary, so only a small amount of code is statically linked into your part. 
  51.  
  52.  
  53.  
  54. C++ Wrapper Classes
  55.  
  56. FW_CString is an example of a wrapper class.  Wrapper classes are thin wrappers around some other implementation.  ODF uses wrapper classes for much of the functionality implemented in ODFLibrary.  These wrapper classes are part of the public interface of ODF and are fully documented.  It is interesting to note that wrapper classes allowed us to minimize the impact of moving to a shared library architecture.  In ODF R2 there are wrapper classes whose interfaces are nearly identical to the full-fledged C++ classes from ODF 1.0d11.
  57.  
  58. Wrapper classes are not just used for wrapping the procedural C functions in ODFLibrary.  ODF provides some wrapper classes that wrap SOM classes from the ODF library as well.  For example,  FW_OFile is a SOM class defined in ODFLibrary.  In previous (pre-)releases of ODF, files were implemented using the FW_CFile class.  FW_CFile was designed to be used as a stack-based object.  Creating a FW_CFile  object opened the file, and destroying the FW_CFile object closed the file.  By placing the object on the stack, it was possible to guarantee that the file would be closed when the object went out of scope, even if an exception was thrown. SOM classes, however, cannot be created on the stack.  We did not want to give up the exception safety we get from creating FW_CFile objects on the stack, so we created a C++ class, FW_PFile,  to wrap the FW_OFile class.
  59.  
  60.  
  61.  
  62. Smart Pointers
  63.  
  64. FW_PFile is a C++ class that wraps the SOM class FW_OFile.  FW_PFile and FW_OFile together provide an interface and functionality almost identical to the old class FW_CFile.  Developers who used pre-release versions of ODF and had references to FW_CFile objects can very likely just search for FW_CFile and replace it with FW_PFile and their code will work (assuming other similar renamings are performed, and some . operators are changed to -> operators). So why didn't we leave FW_CFile named as it was? FW_PFile uses the P prefix instead of the C prefix because it is a smart pointer.  A smart pointer is an instance of class that overrides the member-selection operator (->) so that it can act as a pointer to some other representation object.  FW_PFile is a class that has a data member which is a pointer to a FW_OFile representation object, and overrides the operator-> method to allow access to the FW_OFile object.  Given an instance of FW_PFile, you can directly call any of the public member functions of FW_OFile.  Note that by simply defining the operator-> method, the class effectively inherits all of the public protocol of the representation class.  However, this protocol doesn't appear in the class declaration for the smart pointer.  We use the P prefix so that you'll remember that you can use the protocol of the representation class.
  65.  
  66.  
  67.  
  68. Publicly Exported Functions (by Subsystem)
  69.  
  70. There are 21 SOM classes and 96 public procedures exported by the ODFLibrary.  The following summarizes, by subsystem, the public APIs from ODFLibrary for each subsystem.  Note that some subsystems have no public APIs exported by ODFLibrary.  In all such cases, there will be public APIs defined by classes in one of the ODF static libraries that are linked into your part.  See the ODF Class Reference or Engineering Notes for more information.
  71.  
  72. NOTE: We chose to use SOM to make the 21 SOM classes so that it would be possible to create subclasses. However, it is not required that you subclass any of the 21 SOM classes below, and most ODF part developers will have no need to do so.  Furthermore, there exist public C++ wrappers for most of the SOM classes.
  73.  
  74. Foundation::FWCommon
  75.  
  76. This subsystem defines the following public functions:
  77. FW_PrimitiveSetMemory
  78. FW_PrimitiveCopyMemory
  79. FW_PrimitiveFreeBlock
  80. FW_PrimitiveGetBlockSize
  81. FW_PrimitiveResizeBlock
  82. FW_PrimitiveAllocateBlock
  83. FW_PrimitiveCharacterIsSpace
  84. FW_PrimitiveCharacterToLower
  85. FW_PrimitiveCharacterToUpper
  86. FW_PrimitiveStringFindCharacter
  87. FW_PrimitiveStringCatenate
  88. FW_PrimitiveStringCopy
  89. FW_PrimitiveStringDuplicate
  90. FW_PrimitiveStringCompare
  91. FW_PrimitiveStringEqual
  92. FW_PrimitiveStringLength
  93.  
  94. Foundation::FWCollect
  95.  
  96. All exported functions are private.
  97.  
  98. Foundation::FWDebug
  99.  
  100. All exported functions are private.
  101.  
  102. Foundation::FWRunTyp
  103.  
  104. No functions are exported from the shared library.
  105.  
  106. Foundation::FWExcLib
  107.  
  108. No functions are exported from the shared library.
  109.  
  110. Foundation::FWMemory
  111.  
  112. All exported functions are private.
  113.  
  114. Foundation::FWStream
  115.  
  116. All exported functions are private.
  117. This subsystem defines six SOM classes: 
  118. FW_OSink
  119. FW_OBufferedSink
  120. FW_OMemorySink
  121. FW_OObjectRegistry
  122. FW_OBasicObjectRegistry
  123. FW_ORandomAccessSink
  124.  
  125. Foundation::FWString
  126.  
  127. This subsystem defines the following public functions: 
  128. FW_LocaleIsSingleByte
  129. FW_CharIsDoubleByte
  130.  
  131. This subsystem defines five SOM classes: 
  132. FW_OTextRunReader
  133. FW_OTextRunWriter
  134. FW_OMemoryRunReader
  135. FW_OMemoryRunWriter
  136. FW_OStringRunWriter
  137.  
  138. Foundation::FWRefCnt
  139.  
  140. This subsystem defines one SOM class:
  141. FW_ORefCount
  142.  
  143. OS::FWFiles
  144.  
  145. This subsystem defines four SOM classes:
  146. FW_OFile
  147. FW_OFileSink
  148. FW_OFileSpecification
  149. FW_ODirectorySpecification
  150.  
  151. OS::FWOSMisc
  152.  
  153. This subsystem defines the following public functions:
  154. FW_GetODFLibraryVersion
  155.  
  156. OS::FWODMisc
  157.  
  158. All exported functions are private.
  159.  
  160. This subsystem defines one SOM class:
  161. FW_OStorageUnitSink
  162.  
  163. OS::FWResour
  164.  
  165. This subsystem defines four SOM classes:
  166. FW_OResourceFile
  167. FW_OResource
  168. FW_OResourceSink
  169.  
  170. OS::FWThread
  171.  
  172. This subsystem defines the following public functions:
  173. FW_Thread_NoteCreation
  174. FW_Thread_NoteTermination
  175. FW_Thread_NoteSwitch
  176.  
  177. OS::FWToolbx
  178.  
  179. This subsystem defines the following public functions:
  180. FW_MacGetMaxIntersectedDevice
  181. FW_MacZoomWindow
  182. FW_CenterRectOnScreen
  183. FW_GetMainScreenBounds
  184. FW_Beep
  185. FW_GetTickCount
  186. FW_PositionModalDialog
  187. FW_FitWindowToScreen
  188. FW_SetWindowSize
  189. FW_SetWindowPosition
  190. FW_GetWindowSize
  191. FW_GetWindowPosition
  192. FW_SetWindowTitle
  193. FW_GetWindowTitle
  194. FW_GetWindowBorderSize
  195. FW_ScreenToWindow
  196. FW_WindowToScreen
  197.  
  198. OS::FWGraphics
  199.  
  200. This subsystem defines the following public functions:
  201. FW_MacRGBToColor
  202. FW_MacColorToRGB
  203. FW_GetPaletteSize
  204. FW_SetPaletteEntries
  205. FW_GetPaletteEntries
  206. FW_DestroyPalette
  207. FW_NewRegion
  208. FW_CreateRectRegion
  209. FW_CreateOvalRegion
  210. FW_CreateRoundRectRegion
  211. FW_CreateArcRegion
  212. FW_CreatePolygonRegion
  213. FW_CreateLineRegion
  214. FW_DisposeRegion
  215. FW_CopyRegion
  216. FW_CopyRegionTo
  217. FW_GetRegionBoundingBox
  218. FW_OutlineRegion
  219. FW_EmptyRegion
  220. FW_InsetRegion
  221. FW_MapRegion
  222. FW_OffsetRegion
  223. FW_PointInRegion
  224. FW_RectInRegion
  225. FW_IsEmptyRegion
  226. FW_WriteRegion
  227. FW_ReadRegion
  228. FW_UnionRegion
  229. FW_XorRegion
  230. FW_SubtractRegion
  231. FW_IntersectRegion
  232. FW_RegionCode
  233. FW_PtInOval
  234. FW_PtInRoundRect
  235. FW_HitTestLine
  236. FW_HitTestPolygon
  237. FW_LogPoint
  238. FW_LogRect
  239. FW_LogShape
  240. FW_LogTransform
  241.  
  242. Framework::FWSemEvt
  243.  
  244. This subsystem defines one SOM class:
  245. FW_OSemanticInterface
  246.  
  247.  
  248. © 1993 - 1996 Apple Computer, Inc. All rights reserved.
  249. Apple, the Apple Logo, Macintosh, and OpenDoc are trademarks of Apple Computer, Inc., registered in the United States and other countries.